{% extends 'admin-v2/layout.html.twig' %}

{% do script(['libs/jquery-validation.js', 'app/js/admin-v2/operating/certificate/create/index.js']) %}

{% set menu = 'admin_v2_certificate_manage' %}

{% block main %}
  <h4>{{'admin.operation_certificate.certificate.create_btn'|trans}}</h4>
  <form id="certificate-form" class="form-horizontal" method="post" action="{{ path('admin_v2_certificate_create') }}">
    <div class="form-group mtl mbs">
      <div class="col-md-2 control-label">
        <label for="targetId" class="control-label-required">{{'admin.operation_certificate.certificate.resource_choose'|trans}}：</label>
      </div>
      <div class="col-md-4 controls mts">
        <span class="js-target-name"></span>
        <a href="#modal" data-toggle="modal" data-url="{{ path('admin_v2_certificate_target_select', {targetType: certificate.targetType}) }}" >{{'admin.operation_certificate.certificate.resource_choose_btn'|trans}}</a>
        <input class="hidden" name="targetId" id="targetId" value=""/>
      </div>
    </div>

    <div class="form-group mtl mbs">
      <div class="col-md-2 control-label">
        <label for="templateId" class="control-label-required">{{'admin.operation_certificate.certificate.template_choose'|trans}}：</label>
      </div>
      <div class="col-md-4 controls">
        <span class="js-template-name"></span>
        <a href="#modal" data-toggle="modal" data-url="{{ path('admin_v2_certificate_template_select', {targetType: certificate.targetType}) }}" class="btn btn-default btn-sm js-modal-select-btn"><i class="es-icon es-icon-anonymous-iconfont"></i>{{'admin.operation_certificate.certificate.template_choose'|trans}}</a>
        <input class="hidden" name="templateId" id="templateId" value=""/>
      </div>
    </div>

    <div class="form-group mtl">
      <div class="col-md-2 control-label">
        <label for="code" class="control-label-required">{{'admin.operation_certificate.certificate.code'|trans}}：</label>
      </div>
      <div class="col-md-4 controls">
        <input class="form-control" name="code" id="code" data-url="{{ path('admin_v2_certificate_code_check') }}" placeholder="{{'admin.operation_certificate.certificate.code.placeholder'|trans}}"/>
      </div>
    </div>

    <div class="form-group mtl">
      <div class="col-md-2 control-label">
        <label for="deadline" class="control-label-required">{{'admin.operation_certificate.certificate.expiry_day'|trans}}：</label>
      </div>
      <div class="col-md-4 controls">
        <input class="form-control" name="expiryDay" id="expiryDay" placeholder="{{'admin.operation_certificate.certificate.expiry_day.placeholder'|trans}}"/>
      </div>
      <div class="col-md-1 controls mts" style="margin-left: -20px">{{ 'site.date.day'|trans }}</div>
    </div>

    <div class="form-group mtl">
      <div class="col-md-2 control-label">
        <label for="autoIssue" class="control-label-required">{{ 'admin.operation_certificate.certificate.auto_issue'|trans }}：</label>
      </div>
      <div class="col-md-3">
        <span class="es-switch js-auto-issue is-active" style="margin-top: 7px;">
          <input class="es-switch__input" type="text" name="autoIssue" value="1" data-close="0" data-open="1">
        </span>
        <div class="mtl">
          {{'admin.operation_certificate.certificate.issue_rule'|trans}} :
          <span class="color-primary js-auto-send">{{'admin.operation_certificate.certificate.issue_rule.course'|trans}}</span>
          <span class="color-primary hidden js-close-auto">{{'admin.operation_certificate.certificate.issue_rule.course_not_auto'|trans}}</span>
        </div>
      </div>
    </div>

    <input type="hidden" name="description" value="{{ certificate.description }}">
    <input type="hidden" name="targetType" value="{{ certificate.targetType }}">
    <input type="hidden" name="name" value="{{ certificate.name }}">
    <input type="hidden" name="back" value="0">
    <div class="form-group mtl">
      <div class="col-md-2 control-label">
      </div>
      <div class="controls col-md-4">
        <a type="button" class="btn btn-primary ct-mrxl" id="create-certificate" data-url="{{ path('admin_v2_certificate_create_detail') }}" data-submitting-text="{{'form.btn.save.submiting'|trans}}">{{ 'form.btn.create'|trans }}</a>
        <a type="button" class="btn btn-default ct-mrxl" id="create-certificate-back" data-url="{{ path('admin_v2_certificate_create') }}" data-submitting-text="{{'form.btn.save.submiting'|trans}}">{{ 'form.btn.back'|trans }}</a>
      </div>
    </div>
    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
  </form>
{% endblock %}